﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aribaccio.Device
{
    /// <summary>
    /// 设备连接接口
    /// </summary>
    /// <typeparam name="TPara">设备链接参数接口</typeparam>
    public interface IDevice<TPara> where TPara : IDevicePara
    {
        /// <summary>
        /// 设备是否被打开
        /// </summary>
        bool IsOpen { get; }
        /// <summary>
        /// 设备是否被使用
        /// </summary>
        bool IsUsed { get; set; }
        /// <summary>
        /// 设备地址端口
        /// </summary>
        string AddressPort { get; }
        /// <summary>
        /// 设备参数接口对象
        /// </summary>
        TPara DevicePara { get; set; }
        /// <summary>
        /// 数据交互的锁
        /// </summary>
        SimpleHybirdLock HybirdLock { get; set; }
        /// <summary>
        /// 存储设备数据集合
        /// </summary>
        List<IDeviceTrans<IDeviceData<IDevice<IDevicePara>>>> DeviceDataNode { get; set; }

        /// <summary>
        /// 打开设备连接
        /// </summary>
        /// <returns>是否成功</returns>
        Result Open();

        /// <summary>
        /// 关闭设备连接
        /// </summary>
        /// <returns>是否成功</returns>
        Result Close();

        /// <summary>
        /// 绑定设备连接
        /// </summary>
        /// <param name="argDeviceTransData">设备传输数据接口</param>
        /// <returns></returns>
        IDevice<TPara> BindingDevice(IDeviceTrans<IDeviceData<IDevice<IDevicePara>>> argDeviceTransData);
     
        /// <summary>
        /// 绑定设备清除
        /// </summary>
        /// <param name="argDeviceTransData">设备传输数据接口</param>
        /// <returns></returns>
        void ClearBindingDevice(IDeviceTrans<IDeviceData<IDevice<IDevicePara>>> argDeviceTransData);
    }
}
